/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import entity.Ownership;
import entity.Player;
import entity.Storage;
import java.util.Collection;
import javax.ejb.EJB;
import javax.ejb.Stateful;
import session.manager.PlayerManagerBeanLocal;

/**
 *
 * @author antonio
 */
@Stateful
public class ModifyPlayerSessionBean implements ModifyPlayerSessionBeanLocal {

    private Player player;
  
    @EJB
    private PlayerManagerBeanLocal playerManager;

    @Override
    public Player getPlayer() {
        return this.player;
    }

    @Override
    public void setPlayer(Player player) {
        this.player = player;
    }

    @Override
    public Collection<Storage> getStorages() {
        return this.player.getStorageCollection();
    }

    @Override
    public void update() {
       this.playerManager.edit(player);
    }

    @Override
    public void initPlayer(String remoteUser) {
        this.player = playerManager.find(remoteUser);
        System.out.println(remoteUser+" "+player);
    }

    @Override
    public Collection<Ownership> getOwnership() {
        return this.player.getOwnershipCollection();
    }
    
}
